<template>
    <div id="dialog-container">
        <el-dialog v-dialogDrag 
            :title="dialogTitle" append-to-body
            :visible.sync="dialogVisible" @close="$emit('update:show', false)" :before-close="handleClose" :show="show"
            :close-on-click-modal="false" width="680px">
            <el-form :model="form" :inline="true" size="small" label-width="100px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="工号：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="用户姓名：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="密码：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="厂：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="确认密码：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="职务：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="部门：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="科室：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="邮件地址：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="备注：">
                            <el-input v-model="form.name" type="textarea" :row="2" style="width: 520px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                <el-button @click="dialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                dialogTitle: '新建账号信息',
                dialogVisible: this.show,
                form: {
                    name: ''
                }
            }
        },
        props: {
            show: {
                type: Boolean,
                default: false
            },
            // 判断弹框类型是新增或修改或详情
            sort: {
                type: Number,
                default: 0
            }
        },
        watch: {
            show() {
                this.dialogVisible = this.show;
                // 动态显示dialog的title
                this.sort === 0 ? this.dialogTitle='新建账号信息' :  this.dialogTitle='编辑账号信息';
            }
        },
        methods: {
            handleClose() {
                this.dialogVisible = false;
            }
        }
    }
</script>

